using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
namespace Gameplay
{

    public class Weapon : MonoBehaviour
    {
        [SerializeField] private float _damageValue;

        private Character _owner;
        private BoxCollider _boxCollider;

        private void Awake()
        {
            _boxCollider = GetComponent<BoxCollider>();
        }
        public void SetOwner(Character character) 
        {
            _owner = character;
          
        }
        public void HitCollider(bool active) 
        {
            _boxCollider.enabled = active;
        }

        private void OnTriggerEnter(Collider other)
        {
            Character character=other.GetComponent<Character>();
            if (character != null) 
            {
                Vector3 closesPoint=other.ClosestPoint(transform.position);
                character.TakeDamage(_owner,_owner.SkillManager.CurrentUseSkill.Config.DamageValue,closesPoint);
            }
        }
    }
}
